//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================

#ifndef ___DISPLAY_H__
#define ___DISPLAY_H__

//#define RGBT666PACKED_ENABLE

#define LCD_WIDTH		240
#define LCD_HEIGHT		320
#define LCD_BPP_DIS		18	// bit per pixel

#ifdef RGBT666PACKED_ENABLE

#define BASEPLANE_COLORFORMAT COLOR_RGBT666PACKED
#define BASEPLANE_PIXELBYTES	3
#define BASEPLANE_PIXELBITS     24

#else

#define BASEPLANE_COLORFORMAT COLOR_RGBT666
#define BASEPLANE_PIXELBYTES    4
#define BASEPLANE_PIXELBITS     32

#endif // RGBT666PACKED_ENABLE

#define OVERLAY1_PIXELBYTES 4

#define __PAGESIZE 0x1000
#define ROUNDUP_PAGE(n)     (((n) + (__PAGESIZE) - 1) & ~((__PAGESIZE) - 1))

#define DESC_SIZE            (0x20)
#define BASEPLANE_FB_SIZE    \
    ROUNDUP_PAGE((LCD_WIDTH * LCD_HEIGHT * BASEPLANE_PIXELBYTES))
#define OVERLAY1_FB_MAXSIZE \
    ROUNDUP_PAGE((LCD_WIDTH * LCD_HEIGHT * OVERLAY1_PIXELBYTES))
#define OVERLAY2Y_FB_MAXSIZE    \
    ROUNDUP_PAGE((LCD_WIDTH * LCD_HEIGHT))  // Max size of Y Chan
#define OVERLAY2Cb_FB_MAXSIZE   \
    ROUNDUP_PAGE((LCD_WIDTH * LCD_HEIGHT / 2))  // Max size of Cb Chan
#define OVERLAY2Cr_FB_MAXSIZE  OVERLAY2Cb_FB_MAXSIZE   // Max size of Y Chan
#define OVERLAY2TOTAL_FB_MAXSIZE \
    (OVERLAY2Y_FB_MAXSIZE + OVERLAY2Cb_FB_MAXSIZE + OVERLAY2Cr_FB_MAXSIZE)

#define BASEPLANE_FB_PAGES (BASEPLANE_FB_SIZE >> PAGE_SHIFT)
#define OVERLAY1_FB_PAGES (OVERLAY1_FB_MAXSIZE >> PAGE_SHIFT)
#define OVERLAY2_FB_PAGES (OVERLAY2TOTAL_FB_MAXSIZE >> PAGE_SHIFT)

typedef struct {
    unsigned int paBasePlane ;
    unsigned int paOverlay1  ;
    unsigned int paOverlay2Y ;
    unsigned int paOverlay2Cb;
    unsigned int paOverlay2Cr;
    unsigned int paPalette;

    unsigned int vaBasePlane ;
    unsigned int vaOverlay1  ;
    unsigned int vaOverlay2Y ;
    unsigned int vaOverlay2Cb;
    unsigned int vaOverlay2Cr;
    unsigned int vaPalette;

    unsigned int vaChan0Desc ; // Baseplane descriptor
    unsigned int vaChan1Desc ; // Overlay1 channel descriptor
    unsigned int vaChan2Desc ; // Overlay2 Y channel descriptor
    unsigned int vaChan3Desc ; // Overlay2 Cb channel descriptor
    unsigned int vaChan4Desc ; // Overlay2 Cr channel descriptor
    unsigned int vaChan1AltDesc; // Overlay1 alterable channel descriptor
    unsigned int vaPaletteDesc; // Palette descriptor

    unsigned int paChan0Desc ; // Baseplane descriptor
    unsigned int paChan1Desc ; // Overlay1 channel descriptor
    unsigned int paChan2Desc ; // Overlay2 Y channel descriptor
    unsigned int paChan3Desc ; // Overlay2 Cb channel descriptor
    unsigned int paChan4Desc ; // Overlay2 Cr channel descriptor
    unsigned int paChan1AltDesc; // Overlay1 alterable channel descriptor
    unsigned int paPaletteDesc; // Palette descriptor
} Display_Address;

#endif // ___DISPLAY_H__
